package com.ruoyi.rocky.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.rocky.domain.PcAddTrackingNumber;
import com.ruoyi.rocky.domain.PcOrder;
import com.ruoyi.rocky.domain.PcOrderQuery;
import com.ruoyi.rocky.service.PcOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@Slf4j
@Validated
@RestController
@RequestMapping("/pcOrder")
@AllArgsConstructor
@Api(tags = "订单管理")
public class PcOrderController extends BaseController {


    @Autowired
    private PcOrderService pcOrderService;

    /**
     * 查询订单列表
     */
    @ApiOperation(value = "查询订单列表")
    @GetMapping("/list")
    public TableDataInfo list() {
        startPage();
        List<PcOrder> list = pcOrderService.selectPcOrderList();
        return getDataTable(list);
    }


    /**
     * 根据订单状态或门店或车辆查询订单
     *
     * @param orderQuery
     * @return
     */
    @ApiOperation(value = "根据订单状态或门店或车辆查询订单")
    @GetMapping("/orderList")
    public TableDataInfo selectPcOrderByOrderId(PcOrderQuery orderQuery) {
        startPage();
        List<PcOrder> pcOrders = pcOrderService.selectPcOrder(orderQuery);
        return getDataTable(pcOrders);
    }


    /**
     * 添加订单号
     * @param trackingNumber
     * @return
     */
    @ApiOperation(value = "添加订单号")
    @PostMapping("/addTrackingNumber")
    public R addTrackingNumber(PcAddTrackingNumber trackingNumber) {
        return pcOrderService.addTrackingNumber(trackingNumber);
    }


}
